//
// Created by postgres on 6/23/17.
//

#ifndef MYDATASTRUCTURES_BTREEPLUS_H
#define MYDATASTRUCTURES_BTREEPLUS_H
#include "../common/common.h"
#define max_degree 5
#define KeyType char
#define Boolean char
#define KeyType_NULL '\0'
typedef struct BTNodePlus
{
    int keynum;
    bool is_leaf;
    KeyType data[max_degree+1];
    struct BTNodePlus *child[max_degree+1];
    struct BTNodePlus *parent;
    struct BTNodePlus *prev;
    struct BTNodePlus *next;
}BTNodePlus,*BTreePlus;
typedef struct RSet
{
    BTNodePlus *node; /*成功返回该结点，失败返回应该插入的结点*/
    int pos; //返回Ai-1
    int flag; /*flag=1 成功,flag=0失败 */
    int null_child_index; //空孩子位置.当情形3循环到情形2时，孩子过继插入的位置
}RSet;
typedef struct ResKey
{
    KeyType key;
    int flag; /*flag=1 成功,flag=0失败 */
}ResKey;
void BTreePlus_print(BTreePlus tree, int layer);
int BTreePlus_Main();
void adjust_node_index(BTreePlus *node,int j);
#endif //MYDATASTRUCTURES_BTREEPLUS_H
